/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Application.MainForm;

import java.awt.*;
import Application.Elements.Osc;
/**
 * Az Osc osztalyt megjelenito control
 * @author Stikmann
 */
public class OscControl extends Canvas{
    private Osc osc;

    public OscControl(Osc aosc){
        super();
        osc=aosc;
        setSize(70,35);
    }

    /**
     * A java hivja meg, ha ujra kell rajzolni a controlt
     * @param g
     */
    @Override
    public void paint(Graphics g){
        int from=0;

        g.setColor(Color.black);
        g.fillRect(0,0,70,35);
        g.setColor(Color.green);
        if (osc.history.size()>14)
            from=osc.history.size()-14;
        for(int i=from;i<osc.history.size();++i)
        {
            int y=osc.history.get(i)?10:25;
            g.drawLine((i-from)*5, y, (i-from+1)*5, y);
            if (i>from && osc.history.get(i)!=osc.history.get(i-1))
                g.drawLine((i-from)*5,10,(i-from)*5,25);
        }
    }

    /**
     * Ervenyteleniteskor hivja meg a java a fuggvenyt, ami jelen esetben ujra
     * is rajzoltatja a controlt.
     */
    @Override
    public void invalidate(){
        super.invalidate();
        this.repaint();
    }
}

